﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XSTDZ.ERP.Domain.Models
{
    /// <summary>
    /// 商品类别
    /// </summary>
    public partial class ProductType
    {
        public ProductType()
        {
            this.ProductInfo = new HashSet<ProductInfo>();
            this.ProductTypes = new HashSet<ProductType>();
        }
        public ProductType Init()
        {
            if (this.TypeOrder.Equals(null) || this.TypeOrder <= 0)
            {
                this.TypeOrder = 0;
            }
            if (this.ParentID.Equals(Guid.Empty))
            {
                this.ParentID = this.Id;
            }
            if (this.ParentID==this.Id)
            {
                this.Level = 0;
            }
            else
            {
                 this.Level = this.Parent.Level + 1;
            }
            this.Deleted = 0;
            return this;
        }
        /// <summary>
        /// 设置删除状态（若为删除，则置为正常，否则为删除）
        /// </summary>
        /// <returns></returns>
        public ProductType SetDeleteState()
        {
            this.Deleted = this.Deleted == 0 ? 1 : 0;
            return this;
        }
    }
}
